{% extends 'admin/indexBase.html' %}

{% block title %}订单管理{% endblock %}

{% block search %}
    <form class="navbar-form navbar-right" method="get" action="{{ url_for('orderAdmin.search_order') }}">
        <input type="text" class="form-control" name="kw" placeholder="Search...Orders">
        <input type="submit" class="form-control" value="搜索">
    </form>
{% endblock %}

{% block main %}
    <div>
        <h3 class="title row">订单详情</h3>
        <div>
            <div class="row col-md-offset-1">
                <p><strong>订单号： </strong>{{ order.order_no }}</p>
                <p><strong>下单用户id： </strong><a href="{{ url_for('building.building') }}"
                                             title="userinfo">{{ order.user_id }}</a></p>
                <p><strong>金额： </strong>{{ order.amount }}</p>
                <p><strong>订单状态： </strong>
                    {% if order.status == 0 %}
                        待付款
                    {% elif order.status == 1 %}
                        待发货
                    {% elif order.status == 2 %}
                        待收货
                    {% elif order.status == 3 %}
                        待评价
                    {% elif order.status == 4 %}
                        交易成功
                    {% elif order.status == 6 %}
                        申请退款
                    {% else %}
                        已失效
                    {% endif %}
                </p>
                <p class="time"><strong>下单时间： </strong>{{ order.create_time }}</p>
            </div>
            <div class="row">
                <h4>收货人信息</h4>
                <div class="col-md-offset-1">
                    <p><strong>收货人： </strong>{{ order.address.name }}</p>
                    <p><strong>联系方式： </strong>{{ order.address.tel }}</p>
                    <p><strong>收货地址： </strong>{{ order.address.province }} {{ order
                        .address.city }} {{ order.address.district }} {{ order.address.details }}</p>
                </div>
            </div>
            <div class="row">
                <h4>物流状态</h4>
                <div class="info col-md-offset-1">
                    <ul class="list-unstyled">
                        {% for logistics in  order.logistics %}
                            <li> | {{ logistics.create_time }} —— {{ logistics.info }}</li>
                        {% endfor %}
                    </ul>
                </div>
            </div>
            <div class="row">
                <h4>商品信息</h4>
                <div class="row col-md-offset-1">
                    <ul class="list-unstyled">
                        {% for book in order.books %}
                            <li>
                                <label class="left">{{ book.book.title }}</label>
                                <button class="btn btn-primary" type="button"
                                        data-toggle="collapse" data-target="#{{ book.book._id }}"
                                        aria-expanded="false" aria-controls="collapseExample">
                                    <span class="glyphicon glyphicon-align-left" aria-hidden="true"></span>
                                </button>
                            </li>
                        {% endfor %}
                    </ul>
                </div>
            </div>
            <div class="row">
                {% for book in order.books %}
                    <div class="collapse" id="{{ book.book._id }}">
                        <div class="well col-md-12">
                            <div class="col-md-1">
                                <img src="{{ book.book.img_url }}" style="height: 100px">
                            </div>
                            <div class="col-md-3">
                                <p>{{ book.book.title }}</p>
                                <p>售价：{{ book.book.price }}￥</p>
                                <p style="text-decoration:line-through">原价：{{ book.book.price_m }}￥</p>
                            </div>
                            <div class="col-md-3">
                                <p>库存：{{ book.book.stock }}</p>
                                <p>种类：{{ book.book.category }}</p>
                                <p>类型：{{ book.book.type }}</p>
                            </div>
                            <div class="col-md-3">
                                <p>出版社{{ book.book.press }}</p>
                                <p>{{ book.book.pub_time }}</p>
                                <p>作者：{{ book.book.author }}</p>
                            </div>
                        </div>
                    </div>
                {% endfor %}
            </div>
        </div>
    </div>
{% endblock %}